package com.cx.mall.api.order;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.cx.mall.common.model.order.OrderInfo;
import com.cx.mall.common.utils.ResponseVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(contextId = "orderInfo",name = "mall-order-service")
@SentinelResource
public interface OrderInfoFeign {
    @GetMapping("/order/orderInfo/user/{id}")
    public ResponseVO listByUserId(@PathVariable("id") Long id);

    @PostMapping("/order/orderInfo/save")
    public ResponseVO save(@RequestBody OrderInfo orderInfo);

    @PutMapping("/order/orderInfo/update")
    public ResponseVO update(@RequestBody OrderInfo orderInfo);

    @GetMapping("/order/orderInfo/{id}")
    public ResponseVO getById(@PathVariable("id") String id);

    /**
     * 根据订单ID删除订单
     * @param orderId 订单ID
     * @return 响应体，success为true表示删除成功
     */
    @DeleteMapping("/order/info/delete")
    ResponseVO<Boolean> deleteById(@RequestParam("orderId") String orderId);

    /**
     * 更新订单状态
     * @param orderId 订单ID
     * @param status 状态码（0-待支付，1-已支付，-1-支付失败，-2-支付超时）
     * @return 响应体，success为true表示更新成功
     */
    @PostMapping("/order/info/update/status")
    ResponseVO<Boolean> updateStatus(
            @RequestParam("orderId") Long orderId,
            @RequestParam("status") Integer status
    );
}